import Vue from 'vue'

const filters = {
  empty (value, empty = '/') {
    return (value === undefined || value === null || value === '') ? empty : value
  },

  address (user_info) {
    const { state, district, street, post_code } = user_info
    return (state && district && street && post_code) ? `${state},${post_code},${district},${street}` : '/'
  },

  gender (gender) {
    return gender === null ? '/' : (gender === '1' ? '男' : '女')
  },
}

Object.keys(filters).forEach((key) => {
  Vue.filter(key, filters[key])
})
